package com.amoby.main.action.order;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.amoby.base.common.BaseAction;
import com.amoby.base.common.Pager;
import com.amoby.base.utils.DateUtils;
import com.amoby.main.service.PushSmsService;

 /**
 * @desc:短信日志
 * @author Lasing 2016-3-2 下午2:39:25
 * @version V1.0
 */
@Controller
public class PushSmsLogAction extends BaseAction {
    protected Log              log = LogFactory.getLog(getClass());
    @Autowired
    private PushSmsService pushSmsService;

    /**
     * 初始化页面
     * @author Lasing 2016-3-2 下午2:50:07
     * @param model
     * @param request
     * @param response
     * @return
     */
    @RequestMapping(value = "/menus/pushsms.html")
    public String init(ModelMap model, HttpServletRequest request, HttpServletResponse response) {
        String today = DateUtils.getToday("yyy-MM-dd");
        model.put("startDate", today);
        model.put("endDate", today);
        model.put("orderNo", request.getParameter("orderNo"));
        return AD_HTML + "order/sms_mgr";
    }

    /**
     * 短信日志
     * @author Lasing 2016-3-2 下午2:52:31
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/pushsms/list.html")
    public Object list(HttpServletRequest request) {
        Pager pager = createPager(request);
        pager.addParam("orderNo", getRequestParams(String.class, request, "orderNo"));
        pager.addParam("startDate", getRequestParams(String.class, request, "startDate"));
        pager.addParam("endDate", getRequestParams(String.class, request, "endDate"));
        pager.addParam("dsStatus", getRequestParams(String.class, request, "dsStatus"));
        pager.addParam("tsStatus", getRequestParams(String.class, request, "tsStatus"));
        pager.addParam("dStatus", getRequestParams(String.class, request, "dStatus"));
        pager.addParam("tStatus", getRequestParams(String.class, request, "tStatus"));
        pager = pushSmsService.queryPage(pager);
        return getGridData(pager);
    }
    /**
     * 短信详情
     * @author Lasing 2016-3-2 下午5:49:20
     * @param request
     * @param model
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/pushsms/sms_data.html")
    public Object goodsList(HttpServletRequest request, ModelMap model) {
        Pager pager = createPager(request);
        pager.addParam("orderNo", getRequestParams(String.class, request, "orderId"));
        pager.addParam("type", getRequestParams(String.class, request, "type"));
        pager = pushSmsService.querySmsPager(pager);
        return getGridData(pager);
    }
    
}
